#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{

	int pf;
	int re;
	char buf[32] = {0};

	//打开文件
	pf = open(".myfifo", O_RDONLY);
	if(pf < 0)
	{
		perror("open");

	}

	//读文件
	while(1)
	{
		re = read(pf, buf, 32);
		if(re < 0)
		{

			perror("read");
		}else if(re > 0)
		{
			printf("read: %s\n", buf);
		}else
		{
			exit(0);
		}


	}
}
